package cn.appsys.util;

import java.util.ArrayList;
import java.util.List;

public class Pages<T> {
	private Integer currentPageNo = 1; // 页码
	private Integer pageSize = 5; // 每页显示条数
	private Integer totalCount; // 总记录数
	private Integer totalPageCount; // 总页数
	private List<T> list = new ArrayList<T>();

	public Integer getCurrentPageNo() {
		return currentPageNo;
	}

	public void setCurrentPageNo(Integer currentPageNo) {
		if (currentPageNo <= 0) {
			this.currentPageNo = 1;
		} else if (totalPageCount != 0 && currentPageNo > totalPageCount) {
			currentPageNo = totalPageCount;
		}
		this.currentPageNo = currentPageNo;
	}

	public Integer getPageSize() {
		return pageSize;
	}

	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}

	public Integer getTotalCount() {
		return totalCount;
	}

	public void setTotalCount(Integer totalCount) {
		this.totalCount = totalCount;
		this.totalPageCount = totalCount % pageSize == 0 ? totalCount / pageSize : totalCount / pageSize + 1;
	}

	public Integer getTotalPageCount() {
		return totalPageCount;
	}

	public void setTotalPageCount(Integer totalPageCount) {
		this.totalPageCount = totalPageCount;
	}

	public List<T> getList() {
		return list;
	}

	public void setList(List<T> list) {
		this.list = list;
	}
}
